package net.bcxuexi.socket.model;

/**
 * 端口映射数据模型
 */
public class IPort {
	/**
	 * 内网ip地址
	 */
	private String ip = "127.0.0.1";
	/**
	 * 内网需要暴露到外网的端口
	 */
	private int port = 22;
	/**
	 * 外网代理端口
	 */
	private int proxy = 22;

	private String serverSocketIp = "";

	private int serverSocketPort;

	public IPort(int proxy, String ip, int port, String serverSocketIp,
			int serverSocketPort) {
		this.ip = ip;
		this.port = port;
		this.proxy = proxy;
		this.serverSocketIp = serverSocketIp;
		this.serverSocketPort = serverSocketPort;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public int getProxy() {
		return proxy;
	}

	public void setProxy(int proxy) {
		this.proxy = proxy;
	}

	@Override
	public String toString() {
		String msg = "ip=" + ip + ",port=" + port + ",proxy=" + proxy
				+ ",serverSocketIp=" + serverSocketIp + ",serverSocketPort="
				+ serverSocketPort;
		return msg;
	}

	public String getServerSocketIp() {
		return serverSocketIp;
	}

	public void setServerSocketIp(String serverSocketIp) {
		this.serverSocketIp = serverSocketIp;
	}

	public int getServerSocketPort() {
		return serverSocketPort;
	}

	public void setServerSocketPort(int serverSocketPort) {
		this.serverSocketPort = serverSocketPort;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		IPort iport2 = (IPort) obj;
		if (this.getIp().equals(iport2.getIp())
				&& this.getPort() == iport2.getPort()
				&& this.getProxy() == iport2.getProxy()) {
			return true;
		}
		return false;
	}

	@Override
	public int hashCode() {
		int result = 17;
		result = 37 * result + ip.hashCode();
		result = 23 * result + (int) port;
		result = 29 * result + (int) proxy;
		return result;
	}

}
